package com.rain.entity;

import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import com.rain.enums.DateTimePatternEnum;
import com.rain.utils.DateUtil;

/**
 * @auther: rain
 * @description: 系统日志记录表
 * @date: 2025-10-31
 */
public class Logs implements Serializable {

	/**
	 * 主键ID，自增
	 */
	private Long id;

	/**
	 * 关联的用户ID（可为空，如系统日志）
	 */
	private Long userId;

	/**
	 * 操作行为名称，例如：USER_LOGIN, ORDER_CREATE
	 */
	private String action;

	/**
	 * 日志级别：INFO、WARN、ERROR
	 */
	private String level;

	/**
	 * 详细日志信息，如错误描述、操作说明等
	 */
	private String message;

	/**
	 * 附加信息（JSON格式），如请求参数、响应结果等
	 */
	private String additionalData;

	/**
	 * 日志创建时间，默认为当前时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createdAt;

	/**
	 * 客户端IP地址（IPv4/IPv6兼容）
	 */
	private String ipAddress;

	public void setId(Long id)  { 
		this.id = id;
	}

	public Long getId( ) { 
		return this.id;
	}

	public void setUserId(Long userId)  { 
		this.userId = userId;
	}

	public Long getUserId( ) { 
		return this.userId;
	}

	public void setAction(String action)  { 
		this.action = action;
	}

	public String getAction( ) { 
		return this.action;
	}

	public void setLevel(String level)  { 
		this.level = level;
	}

	public String getLevel( ) { 
		return this.level;
	}

	public void setMessage(String message)  { 
		this.message = message;
	}

	public String getMessage( ) { 
		return this.message;
	}

	public void setAdditionalData(String additionalData)  { 
		this.additionalData = additionalData;
	}

	public String getAdditionalData( ) { 
		return this.additionalData;
	}

	public void setCreatedAt(Date createdAt)  { 
		this.createdAt = createdAt;
	}

	public Date getCreatedAt( ) { 
		return this.createdAt;
	}

	public void setIpAddress(String ipAddress)  { 
		this.ipAddress = ipAddress;
	}

	public String getIpAddress( ) { 
		return this.ipAddress;
	}

	@Override
	public String toString()  {
		return " Logs { id: " + id + ", " + "userId: " + userId + ", " + "action: " + action + ", " + "level: " + level + ", " + "message: " + message + ", " + "additionalData: " + additionalData + ", " + "createdAt: " + DateUtil.format(createdAt, DateTimePatternEnum.YYYY_MM_DD_HH_MM_SS.getPattern()) + ", " + "ipAddress: " + ipAddress + " } ";
	}
}